<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Poorcoverage,com.ejoysoft.wlanyz.business.PoorcoverageAP,com.ejoysoft.wlanyz.business.Poorcoverage2,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException,java.sql.*" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
     if(!globa.userSession.hasRight("20010"))
     throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
  
%>
<%
   
    //查询条件
    String  classOneAc=ParamUtil.getString(request,"classone","").trim();//获取一级热点
    String  classTwoAc=ParamUtil.getString(request,"classtwo","").trim();//获取二级热点
    String  strCity=ParamUtil.getString(request,"city","").trim();//获取城市
    String  strCountry=ParamUtil.getString(request,"country","").trim();//获取区县
    String  timedegree=ParamUtil.getString(request,"timedegree","").trim();//获取时间粒度
    String strStartTime = ParamUtil.getString(request,"strStartTime","");//获取起始时间
	String strEndTime = ParamUtil.getString(request,"strEndTime","");//获取结束时间
    String exportContent = ParamUtil.getString(request,"exportContent","");
    String exportFlag = ParamUtil.getString(request,"exportFlag","");
    int intCurPage = ParamUtil.getInt(request,"intCurPage");//当前页
   
    //System.out.println("****************");
	//System.out.print(intCurPage);
    String tWhere=" WHERE 1=1 ";
	if (!strCity.equals("") && strCountry.equals("")) {
		tWhere += " and strcity LIKE '%" + strCity + "%'";
	}
	else if(strCity.equals("") && !strCountry.equals("")){
	    tWhere += "  and strcountry LIKE '%" + strCountry + "%'";
	    }
	    else if(!strCity.equals("") && !strCountry.equals("")){
	    tWhere += " and strcity LIKE '%" + strCity + "%' and strcountry LIKE '%" + strCountry + "%' ";
	    }
	    
	    
if(exportFlag.equals("poor_coverage"))
{
//初始化
    Poorcoverage  Poorcoverage0=null;
    Poorcoverage obj=new Poorcoverage(globa);
    	//记录总数
	int intAllCount=obj.getCount1(tWhere);	

 //每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
    
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<Poorcoverage> vctObj=obj.list1(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
		if(exportContent.equals("allPage"))
		{ 
			vctObj=obj.list1(timedegree,tWhere,0,0,strStartTime,strEndTime);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县数量,一级热点数量,AP数量,是否弱覆盖,弱覆盖AP数,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getCountryNum()+ ",";
		       strSb += vctObj.get(i).getacNumber()+ ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getpoorCover().replace("\n","") + ",";
		       strSb += vctObj.get(i).getpoorCoverNum() + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+"弱覆盖分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());   
}
else if(exportFlag.equals("poor_coverage_country"))
{ 
   //初始化
    Poorcoverage2  PoorcoverageAP0=null;
    Poorcoverage2 obj=new Poorcoverage2(globa);
	//记录总数
	int intAllCount=obj.getCount1(tWhere);	
	 //每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
    
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Poorcoverage2> vctObj=obj.list11(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
	//System.out.println("exportContent=="+exportContent);
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list11(timedegree,tWhere,0,0,strStartTime,strEndTime);
	
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点数量,AP数量,是否弱覆盖,弱覆盖AP数,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrProper().replace("\n","") + ",";
		       strSb += vctObj.get(i).gethotSpotacNum() + ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getpoorCover().replace("\n","") + ",";
		       strSb += vctObj.get(i).getpoorCoverNum() + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+strCountry+"的弱覆盖分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
       
}

else if(exportFlag.equals("poor_coverage_classoneac"))
{ 
if(!classOneAc.equals("")) tWhere += " and classoneac LIKE '%"+classOneAc+"%' ";
   //初始化
    Poorcoverage2  PoorcoverageAP0=null;
    Poorcoverage2 obj=new Poorcoverage2(globa);
	//记录总数
	int intAllCount=obj.getCount12(tWhere);	
	 //每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
    
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Poorcoverage2> vctObj=obj.list12(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
	//System.out.println("exportContent=="+exportContent);
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list12(timedegree,tWhere,0,0,strStartTime,strEndTime);
	
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点,二级热点数量,AP数量,是否弱覆盖,弱覆盖AP数,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrProper().replace("\n","") + ",";
		       strSb += vctObj.get(i).gethotSpot().replace("\n","") + ",";
		       strSb += vctObj.get(i).gethotSpot2acNum() + ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getpoorCover().replace("\n","") + ",";
		       strSb += vctObj.get(i).getpoorCoverNum() + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+strCountry+"一级热点"+classOneAc+"的弱覆盖分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
       
}

	    
else if(exportFlag.equals("poor_coverage_classtwoac"))
{
tWhere += " and classoneac = '"+classOneAc+"' ";
if(!classTwoAc.equals("")) tWhere += " and classtwoac LIKE '%"+classTwoAc+"%' ";
//初始化
    Poorcoverage  Poorcoverage0=null;
    Poorcoverage obj=new Poorcoverage(globa);
    	//记录总数
	int intAllCount=obj.getCount(tWhere);	

 //每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
    
		//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;  
	//获取到当前页面的记录集
	Vector<Poorcoverage> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
		if(exportContent.equals("allPage"))
		{ 
			vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,一级热点,AP数量,是否弱覆盖,弱覆盖AP数,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrProper().replace("\n","") + ",";
		       strSb += vctObj.get(i).gethotSpot().replace("\n","") + ",";
		       strSb += vctObj.get(i).getapNumber()+ ",";
		       strSb += vctObj.get(i).getpoorCover().replace("\n","") + ",";
		       strSb += vctObj.get(i).getpoorCoverNum() + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+strCountry+"一级热点"+classOneAc+ "的二级热点"+classTwoAc+"弱覆盖分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());   
}

else if(exportFlag.equals("poor_coverage_AP"))
{ 
   tWhere += " and classoneac like '%"+classOneAc+"%' ";
   //初始化
    Poorcoverage2  PoorcoverageAP0=null;
    Poorcoverage2 obj=new Poorcoverage2(globa);
	//记录总数
	int intAllCount=obj.getCount(tWhere,classTwoAc);
	 //每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
    
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Poorcoverage2> vctObj=obj.list(timedegree,tWhere,intStartNum,intPageSize,strStartTime,strEndTime,classTwoAc);
	
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
	//System.out.println("exportContent=="+exportContent);
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(timedegree,tWhere,0,0,strStartTime,strEndTime,classTwoAc);
		}
		StringBuffer sb = new StringBuffer();
	    sb.append("地市,区县,二级热点,AP名称,是否弱覆盖,弱覆盖AP数,用户数,信噪比,场强,信道质量\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getstrCity().replace("\n","") + ",";
		       strSb += vctObj.get(i).getstrProper().replace("\n","") + ",";
		       strSb += vctObj.get(i).gethotSpot().replace("\n","") + ",";
		       strSb += vctObj.get(i).getapName().replace("\n","") + ",";
		       strSb += vctObj.get(i).getpoorCover().replace("\n","") + ",";
		       strSb += vctObj.get(i).getpoorCoverNum() + ",";
		       strSb += vctObj.get(i).getuserNumber()+ ",";
		       strSb += vctObj.get(i).getnoiseRatio()+",";
		       strSb += vctObj.get(i).getfieldIntens()+ ",";
		       strSb += vctObj.get(i).getfrouteQuality()+ ",\n";

			    sb.append(strSb);
		    }
	    }
	    String strFileName =strCity+strCountry+"一级热点"+classOneAc+"二级热点"+classTwoAc+"的AP弱覆盖分析表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
       
}


	%>
<%@ include file="../include/jsp/footer.jsp"%>
